package com.example.exam.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.exam.mapper.TestPaperMapper;
import com.example.exam.pojo.TestPaper;
import com.example.exam.service.TestPaperService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author
 * @date 2023/03/05
 */
@Service
public class TestPaperServiceImpl extends ServiceImpl<TestPaperMapper, TestPaper> implements TestPaperService {

    @Override
    public void insert(TestPaper testPaper) {
        baseMapper.insert(testPaper);
    }

    @Override
    public List<TestPaper> searchAllBySid(String sid) {
        QueryWrapper<TestPaper> wrapper = new QueryWrapper<>();
        wrapper.eq("sid", sid);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public TestPaper searchAllBySidAndTid(String sid, int tid) {
        QueryWrapper<TestPaper> wrapper = new QueryWrapper<>();
        wrapper.eq("sid", sid);
        wrapper.eq("tid", tid);
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public void updateAllBySidAndTid(TestPaper testPaper) {
        baseMapper.updateAllBySidAndTid(testPaper);
    }
}
